package liumengbaio.lolzhangyoubao.Activity.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.zip.Inflater;

import liumengbaio.lolzhangyoubao.Activity.InFo.MoreSpecialInfo;
import liumengbaio.lolzhangyoubao.R;

/**
 * 精彩专栏 适配器
 * Created by lanouhn on 16/9/18.
 */
public class MoreSpecialAdapter extends BaseAdapter {

    private Context mContext;
    private MoreSpecialInfo info;

    public MoreSpecialAdapter(Context mContext, MoreSpecialInfo info) {
        this.mContext = mContext;
        this.info = info;
    }

    @Override
    public int getCount() {
        return info.getData().size();
    }

    @Override
    public Object getItem(int position) {
        return info.getData().get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_more_special, null);
            holder.name = (TextView) convertView.findViewById(R.id.name);
            holder.pic = (ImageView) convertView.findViewById(R.id.pic);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.name.setText(info.getData().get(position).getName());
        Picasso.with(mContext).load(info.getData().get(position).getPic_url()).into(holder.pic);
        return convertView;
    }

    private class ViewHolder {
        private TextView name;
        private ImageView pic;
    }
}
